﻿// Copyright (c) Amer Koleci and contributors.
// Distributed under the MIT license. See the LICENSE file in the project root for more information.

namespace Vortice.Direct3D12
{
    /// <summary>
    /// Describes a static sampler state.
    /// </summary>
    public partial struct StaticSamplerDescription
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="StaticSamplerDescription"/> struct.
        /// </summary>
        /// <param name="shaderVisibility">The shader visibility.</param>
        /// <param name="shaderRegister">The shader register.</param>
        /// <param name="registerSpace">The register space.</param>
        public StaticSamplerDescription(ShaderVisibility shaderVisibility, int shaderRegister, int registerSpace) 
        {
            Filter = Filter.MinMagMipLinear;
            AddressU = TextureAddressMode.Clamp;
            AddressV = TextureAddressMode.Clamp;
            AddressW = TextureAddressMode.Clamp;
            MipLODBias = 0.0f;
            MaxAnisotropy = 1;
            ComparisonFunction = ComparisonFunction.Never;
            BorderColor = StaticBorderColor.TransparentBlack;
            MinLOD = float.MinValue;
            MaxLOD = float.MaxValue;

            ShaderRegister = shaderRegister;
            RegisterSpace = registerSpace;
            ShaderVisibility = shaderVisibility;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="StaticSamplerDescription"/> struct.
        /// </summary>
        /// <param name="samplerDescription">Sampler description</param>
        /// <param name="shaderVisibility">The shader visibility.</param>
        /// <param name="shaderRegister">The shader register.</param>
        /// <param name="registerSpace">The register space.</param>
        public StaticSamplerDescription(SamplerDescription samplerDescription, ShaderVisibility shaderVisibility, int shaderRegister, int registerSpace) : this()
        {
            ShaderVisibility = shaderVisibility;
            ShaderRegister = shaderRegister;
            RegisterSpace = registerSpace;
            BorderColor = StaticBorderColor.TransparentBlack;

            Filter = samplerDescription.Filter;
            AddressU = samplerDescription.AddressU;
            AddressV = samplerDescription.AddressV;
            AddressW = samplerDescription.AddressW;
            MinLOD = samplerDescription.MinLOD;
            MaxLOD = samplerDescription.MaxLOD;
            MipLODBias = samplerDescription.MipLODBias;
            MaxAnisotropy = samplerDescription.MaxAnisotropy;
            ComparisonFunction = samplerDescription.ComparisonFunction;
        }
    }
}
